import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'dart:ui';

class ChatAppBar extends StatelessWidget {
  Widget leftICon;
  String name;
  String desc;
  Widget rightICon;
  Color textColor = Color.fromRGBO(12, 12, 12, 1);
  Color bgColor = Color.fromRGBO(246, 247, 249, 1);
  ChatAppBar({Key key,this.leftICon,@required this.name,this.desc, this.rightICon,this.textColor,this.bgColor}):super(key:key);
  @override
  Widget renderDesc () {
    if (this.desc == null) {
      return SizedBox(
        height: 0.0
      );
    } else {
      return Text(
        this.desc,
        textAlign: TextAlign.center,
        maxLines: 1,
        overflow: TextOverflow.ellipsis,
        style: TextStyle(
          fontSize: ScreenUtil().setWidth(20),
          color: this.textColor
        ),
      );
    }
  }

  Widget build(BuildContext context) {
    return Container(
      width: ScreenUtil().setWidth(750),
      height:ScreenUtil().setHeight(134) - MediaQueryData.fromWindow(window).padding.top,
      decoration: BoxDecoration(
        color: this.bgColor,
        boxShadow: [
          BoxShadow(
            offset: Offset(0.0, 0.0),
            color: Color.fromRGBO(16, 20, 12, 0.8),
            blurRadius: 4.0
          )
        ],
      ),
      child: Row(
        mainAxisAlignment:MainAxisAlignment.spaceBetween,
        children: <Widget>[
          Container(
            width: ScreenUtil().setHeight(134) - MediaQueryData.fromWindow(window).padding.top,
            height: ScreenUtil().setHeight(134) - MediaQueryData.fromWindow(window).padding.top,
            child: this.leftICon,
          ),
          Expanded(
            child: Column(
              mainAxisAlignment:MainAxisAlignment.center,
              children: <Widget>[
                Container(
                  height:ScreenUtil().setWidth(28),
                  child: Text(
                    this.name,
                    maxLines: 1,
                    overflow: TextOverflow.ellipsis,
                    style: TextStyle(
                      fontSize: ScreenUtil().setWidth(30),
                      color: this.textColor
                    )
                  ),
                ),
                renderDesc()
              ],
            ),
          ),
          Container(
            width: ScreenUtil().setHeight(134) - MediaQueryData.fromWindow(window).padding.top,
            height: ScreenUtil().setHeight(134) - MediaQueryData.fromWindow(window).padding.top,
            child: this.rightICon,
          ),
        ],
      ),
    );
  }
}